import 'package:get/get.dart';
import 'package:getx_example/get_connect/model/my_get_connect_model.dart';
import 'package:getx_example/get_connect/my_service/my_get_service.dart';

class MyGetConnectDioController extends GetxController {
  var dataList = Rx<List<MyGetConnectModel>>([]);

  final MyGetConnectDioService getConnectDioService = Get.put<MyGetConnectDioService>(MyGetConnectDioService());

  void getData() async {
    //这里可以自己使用自己的dio封装的请求框架
    // dataList.value = await MyGetConnectDioService().getData();
    // dataList.value = await MyGetConnectDioService().getData();
    //延时
    // await Future.delayed(const Duration(seconds: 2));
    // dataList.value = [
    //   MyGetConnectModel(userId: 123, id: 123, title: "12321", body: "12321"),
    //   MyGetConnectModel(userId: 123, id: 123, title: "12321", body: "12321"),
    //   MyGetConnectModel(userId: 123, id: 123, title: "12321", body: "12321")
    // ];

    //也可以使用getconnect的封装
    //自行处理数据
    // final Response response = await getConnectDioService.getContent();
    dataList.value = [
      MyGetConnectModel(userId: 123, id: 123, title: "12321", body: "12321"),
      MyGetConnectModel(userId: 123, id: 123, title: "12321", body: "12321"),
      MyGetConnectModel(userId: 123, id: 123, title: "12321", body: "12321")
    ];

  }
}



class MyGetConnectDionBuinding extends Bindings {
  @override
  void dependencies() {
    Get.lazyPut(() => MyGetConnectDioController());
  }
}